<?php
use yii\bootstrap\ActiveForm;
use common\helps\tools;
?>
<link rel="stylesheet" href="../static/dist/css/AdminLTE.min.css" type="text/css">
<link rel="stylesheet" href="../static/bootstrap/css/bootstrap.min.css" type="text/css">
<link rel="stylesheet" href="../static/plugins/datatables/jquery.dataTables.css" type="text/css">
<link rel="stylesheet" href="../static/css/admin.css" type="text/css">
<link rel="stylesheet" href="../static/jBox/Skins/Metro/jbox.css" type="text/css">
<link rel="stylesheet" href="../static/plugins/datepicker/datepicker3.css" type="text/css">
<link rel="stylesheet" href="../static/plugins/bootstrap-select/css/bootstrap-select.css" type="text/css">
<style>
    .dataTable>tbody>tr>td{
        vertical-align: middle;
        font-size: 0.8em;
        padding: 8px 18px;
    }
    .dataTable>thead>tr>th{
        vertical-align: middle;
        font-size: 0.8em;
        text-align: center;
    }
    .examine-content .input-group .form-control{
        margin-bottom: 20px;
        height: 30px ;
        line-height: 30px;
    }
    .examine-content button{
        margin: 10px;
    }
    label{
        text-align: right;
    }
    #table_id_example th, td {
        white-space: nowrap;
    }
    #table_list th,td{ font-family: '微软雅黑'; font-size: small; text-align: center}

</style>
<div class="tabs-panel">
    <div class="row">
        <div class="col-xs-12">
            <div class="box">
                <div class="box-body">
                    <div class="col-md-12" style="padding-bottom: 20px">
                        <label class="col-sm-2 control-label"><span class="text-danger">*</span>仓库</label>
                        <div class="col-sm-4">
                            <select id="warehouseId" name="warehouseId" class="selectpicker" data-live-search="true" style="width: 200px">
                                <option value="">选择仓库</option>
                                <?php foreach($warehouse as $value) { ?>
                                    <option value="<?= $value['id']?>" <?=($order&&$order['warehouseId']==$value['id'])?'selected':'' ?>><?= $value['warehouseName']?></option>
                                <?php }?>
                            </select>
                            <button type="button" class="btn btn-default" id="wh-confirm-btn" style="width:70px;">确认</button>&nbsp;&nbsp;
                        </div>
                        <label class="col-sm-2 control-label"><span class="text-danger">*</span>供应商</label>
                        <div class="col-sm-4">
                            <select id="supplierId" name="supplierId" class="selectpicker" data-live-search="true" style="width: 200px">
                                <option value="">选择供应商</option>
                                <?php foreach($supplier as $value) { ?>
                                    <option value="<?= $value['id']?>" <?=($order&&$order['supplierId']==$value['id'])?'selected':'' ?>><?= $value['supplierName']?></option>
                                <?php }?>
                            </select>
                            <button type="button" class="btn btn-default" id="supp-confirm-btn" style="width:70px;">确认</button>&nbsp;&nbsp;
                        </div>
                    </div>

                    <div class="col-md-12" style="padding-bottom: 20px">
                        <label class="col-sm-2 control-label"><span class="text-danger">*</span>采购商抬头名称</label>
                        <div class="col-sm-4">
                            <input type="text" class="form-control" name="purchaserName" id="purchaserName" value="<?=$order? $order['purchaserName'] :''?>">
                        </div>
                    </div>

                    <div class="col-md-12" style="padding-bottom: 20px">
                        <label class="col-sm-2 control-label"><span class="text-danger">*</span>采购日期</label>
                        <div class="col-sm-4">
                            <input type="text" class="form-control" name="purchaseDate" id="purchaseDate" readonly value="<?=$order? date('Y-m-d',strtotime($order['purchaseDate'])) : ''?>">
                        </div>
                        <label class="col-sm-2 control-label"><span class="text-danger">*</span>预计送货日期</label>
                        <div class="col-sm-4">
                            <input type="text" class="form-control" name="pre_deliveryDate" id="pre_deliveryDate" readonly value="<?=$order? date('Y-m-d',strtotime($order['pre_deliveryDate'])) : ''?>">
                        </div>
                    </div>


                    <div class="col-md-12" style="padding-bottom: 20px">
                        <label class="col-sm-2 control-label"><span class="text-danger">*</span>联系人姓名</label>
                        <div class="col-sm-4">
                            <input type="text" class="form-control" name="contactName" id="contactName" value="<?=$order? $order['contactName'] :''?>">
                        </div>
                        <label class="col-sm-2 control-label"><span class="text-danger">*</span>联系人手机</label>
                        <div class="col-sm-4">
                            <input type="text" class="form-control" name="contactMobile" id="contactMobile" value="<?=$order? $order['contactMobile'] :''?>">
                        </div>
                    </div>




                    <div class="col-md-12" style="padding-bottom: 20px">
                        <label class="col-sm-2 control-label"><span class="text-danger">*</span>收货人名称</label>
                        <div class="col-sm-4">
                            <input type="text" class="form-control" name="receiverName" id="receiverName" value="<?=$order? $order['receiverName'] :''?>">
                        </div>
                        <label class="col-sm-2 control-label"><span class="text-danger">*</span>收货人联系方式</label>
                        <div class="col-sm-4">
                            <input type="text" class="form-control" name="receiverInformation" id="receiverInformation" value="<?=$order? $order['receiverInformation'] :''?>">
                        </div>
                    </div>



                    <div class="col-md-12" style="padding-bottom: 20px">
                        <label class="col-sm-2 control-label"><span class="text-danger">*</span>送货地址</label>
                        <div class="col-sm-4">
                            <input type="text" class="form-control" name="deliveryAddress" id="deliveryAddress" value="<?=$order? $order['deliveryAddress'] :''?>">
                        </div>
                        <label class="col-sm-2 control-label">说明</label>
                        <div class="col-sm-4">
                            <input type="text" class="form-control" name="description" id="description" value="<?=$order? $order['description'] :''?>">
                        </div>
                    </div>

                    <div class="col-md-12" style="padding-bottom: 20px">
                        <label class="col-sm-2 control-label">备注</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" name="remark" id="remark" value="<?=$order? $order['remark'] :''?>">
                        </div>
                    </div>



                    <div class="col-md-12">
                        <button type="button" class="btn btn-primary" id="show-materiel-btn" style="width: 100px; margin-bottom: 5px">添加</button>
                        <table id="table_list" class="table table-bordered table-hover">
                            <thead>
                            <tr>
                                <th style="width: 5%">物料ID</th>
                                <th style="width: 9%">物料编码</th>
                                <th style="width: 9%">物料名称</th>
                                <th style="width: 9%">订货规格</th>
                                <th style="width: 9%">订货单位</th>
                                <th style="width: 5%">税率</th>
                                <th style="width: 6%">含税采购单价</th>
                                <th style="width: 5%">去税单价</th>
                                <th style="width: 5%">采购数量</th>
                                <th style="width: 5%">总金额</th>
                                <th style="width: 10%">备注</th>
                                <th style="width: 5%">操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            <?php if($order && $order['dtl']){ foreach ($order['dtl'] as $dtl){ ?>
                                <tr data-code="<?= $dtl['materielId'] ?>">
                                    <td><?= $dtl['materielId'] ?></td>
                                    <td><?= $dtl['materielName'] ?></td>
                                    <td><?= $dtl['materielCode'] ?></td>
                                    <td><?= $dtl['specDesc'] ?></td>
                                    <td><?= $dtl['orderUnit'] ?></td>
                                    <td><input disabled style="width: 80px" name="taxRate" value="<?= $dtl['taxRate'] ?>"></td>
                                    <td><input disabled style="width: 80px" name="referPrice" value="<?= $dtl['referPrice'] ?>"></td>
                                    <td><input disabled style="width: 80px" name="price" value="<?= $dtl['price'] ?>"></td>
                                    <td><input style="width: 80px" name="qty" value="<?= $dtl['qty'] ?>"></td>
                                    <td><input disabled style="width: 80px" name="totalPrice" value="<?= $dtl['totalPrice'] ?>"></td>
                                    <td><input style="width: 100px" name="remark" value="<?= $dtl['remark'] ?>"></td>
                                    <td><?php if($order['status']=='0'){ ?><a name="del-materiel">删除</a><?php } ?></td>
                                </tr>
                            <?php } } ?>
                            </tbody>
                        </table>
                    </div>
                </div>
                <div class="box-footer" style="text-align: right">
                    <button type="button" class="btn btn-default" onclick="history.back();">返回
                    </button>
                    <button type="button" class="btn btn-primary hideBtn" onclick="saveOrder()">提交</button>
                </div>
            </div>
        </div>
    </div>
</div>


<div class="modal fade" id="add-materiel-modal" style="background: rgba(236, 230, 230, 0.3);" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog" style="width: 85%;">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title" id="myModalLabel">添加物料</h4>
            </div>
            <div class="modal-body">
                <div class="box-header">
                    物料名称/编号: <input class="depart-input" id="searchKey" type="text">
                    <button type="button" class="btn btn-primary depart-modal" id="search-btn" style="width: 100px;">查询</button> &nbsp;
                </div>
                <div class="box-body">
                    <table id="search_list" class="display">
                        <thead>
                        <tr>
                            <th style="width: 10%">物料Id</th>
                            <th style="width: 12%">物料编码</th>
                            <th style="width: 15%">物料名称</th>
                            <th style="width: 10%">规格描述</th>
                            <th style="width: 10%">订货单位</th>
                            <th style="width: 11%">税率</th>
                            <th style="width: 11%">参考价格</th>
                            <th style="width: 10%">操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        </tbody>
                    </table>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                <button type="button" class="btn btn-primary" id="add-materiel-btn">添加</button>
            </div>
        </div>
    </div>
</div>

<script type="text/javascript" src="../static/plugins/jQuery/jquery-2.2.3.min.js"></script>
<script type="text/javascript" src="../static/bootstrap/js/bootstrap.min.js"></script>
<script type="text/javascript" src="../static/plugins/datatables/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="../static/plugins/datatables/dataTables.bootstrap.min.js"></script>
<script type="text/javascript" src="../static/jBox/jquery.jBox-2.3.min.js"></script>
<script type="text/javascript" src="../static/jBox/i18n/jquery.jBox-zh-CN.js"></script>
<!-- 自定义js -->
<script type="text/javascript" src="/static/plugins/datepicker/bootstrap-datepicker.js"></script>
<script type="text/javascript" src="/static/plugins/datepicker/locales/bootstrap-datepicker.zh-CN.js"></script>
<script type="text/javascript" src="/static/plugins/bootstrap-select/js/bootstrap-select.js"></script>
<script type="text/javascript" src="/static/plugins/bootstrap-select/js/defaults-zh_CN.js"></script>

<script type="text/javascript" src="/static/app/global.js?version=<?=Yii::$app->params['version']?>"></script>
<script type="text/javascript" src="../static/app/stock/index.js?version=<?=Yii::$app->params['version']?>"></script>

<script>



    var tempData = {};
    var selectData = {};
    var searchDataTable = null;
    var orderNo = '', dateFlg = 0;
    var confirmWhFlg = 0;//确认仓库标记
    var confirmSuppFlg = 0;//确认仓库标记


    var warehouses = <?=json_encode($warehouse)?>;




    <?php if($order){ ?>
    orderNo = '<?=$order['orderNo']?>';
    <?php if($order['status']=='0'){ ?>
    <?php if($order['dtl']){ foreach ($order['dtl'] as $dtl){ ?>
    selectData['<?=$dtl['materielId']?>'] = {
        materielId:'<?=$dtl['materielId']?>',
        materielCode:'<?=$dtl['materielCode']?>',
        materielName:'<?=$dtl['materielName']?>',
        specDesc: '<?=$dtl['specDesc']?>',
        orderUnit: '<?=$dtl['orderUnit']?>',
        taxRate: '<?=$dtl['taxRate']?>',
        referPrice: '<?=$dtl['referPrice']?>',
        price: '<?=$dtl['price']?>',
        qty: '<?=$dtl['qty']?>',
        totalPrice: '<?=$dtl['totalPrice']?>',
        remark: '<?=$dtl['remark']?>'
    };
    confirmWhFlg = confirmSuppFlg = 1;
    $('#wh-confirm-btn').text('重置');
    $('#supp-confirm-btn').text('重置');
    $('#warehouseId').attr('disabled', 'true').css('color', '#ccc');
    $('#supplierId').attr('disabled', 'true').css('color', '#ccc');
    <?php }}} else { ?>
    $('input').attr("disabled","disabled");
    $('#show-materiel-btn').hide();
    $('.hideBtn').hide();
    $('#wh-confirm-btn').hide();
    $('#supp-confirm-btn').hide();
    <?php }} ?>




    //确认、重置仓库
    $("#wh-confirm-btn").on('click', function () {
        if ($(this).text() == '确认') {
            confirmWhFlg = 1;
            if ($('#warehouseId').val() == '') {
                $.jBox.tip('请选择仓库');
                return;
            }
            $('#warehouseId').attr('disabled', 'true').css('color', '#ccc');
            $(this).text('重置');
        } else {
            dateFlg = 1;
            confirmWhFlg = 0;
            selectData = {};
            tempData = {};
            $('#table_list tbody').html('');
            $('#warehouseId').removeAttr('disabled').css('color', '');
            $(this).text('确认');
        }
    });


    //确认、重置仓库
    $("#supp-confirm-btn").on('click', function () {
        if ($(this).text() == '确认') {
            confirmSuppFlg = 1;
            if ($('#supplierId').val() == '') {
                $.jBox.tip('请选择仓库');
                return;
            }
            $('#supplierId').attr('disabled', 'true').css('color', '#ccc');
            $(this).text('重置');
        } else {
            dateFlg = 1;
            confirmSuppFlg = 0;
            selectData = {};
            tempData = {};
            $('#table_list tbody').html('');
            $('#supplierId').removeAttr('disabled').css('color', '');
            $(this).text('确认');
        }
    });



    $(function () {
        $('#purchaseDate').datepicker({ language:'zh-CN', format:'yyyy-mm-dd'} );
        $(document).on('click', 'input[name=purchaseDate]', function () {
            $(this).datepicker({ language:'zh-CN', format:'yyyy-mm-dd', showOn:'focus'} ).focus();
        });

        $('#pre_deliveryDate').datepicker({ language:'zh-CN', format:'yyyy-mm-dd'} );
        $(document).on('click', 'input[name=pre_deliveryDate]', function () {
            $(this).datepicker({ language:'zh-CN', format:'yyyy-mm-dd', showOn:'focus'} ).focus();
        });
    });



    $('#warehouseId').change(function () {
        var select_id = $(this).val();
        if( select_id!="" ) {
            $.each(warehouses, function (i,v) {
                if (v.id == select_id) {
                    $("#receiverName").val(v.contacts);
                    $("#receiverInformation").val(v.mobile);
                    $("#deliveryAddress").val(v.province + v.city + v.area + v.address);
                    return false;
                }
            });
        }else{
            $("#receiverName").val('');
            $("#receiverInformation").val('');
            $("#deliveryAddress").val('');
        }
    });



    //初始化modal
    $('#show-materiel-btn').on('click', function () {

        if (!confirmWhFlg) {
            $.jBox.tip('请确认仓库');
            return;
        }
        if (!confirmSuppFlg) {
            $.jBox.tip('请确认供应商');
            return;
        }


        $('#add-materiel-modal').modal('show');
        if(searchDataTable) {
            if(dateFlg){
                searchDataTable.ajax.reload();
            }
            return;
        }


        var supplierId =   $("#supplierId").val();

        searchDataTable = $('#search_list').DataTable({
            dom: '<"top">rt<"bottom"flip><"clear">',
            language: {
                "sUrl":'../static/plugins/datatables/language.json'
            },
            "searching": false,
            "processing": true,
            "serverSide": true,
            ajax:{
                url:'/stock/get-materiel-list',
                type:'post',
                data:function(d){
                    d.warehouseId = $("#warehouseId").val();
                    d.supplierId = $("#supplierId").val();
                    d.searchKey = $('#searchKey').val();
                    d.storeFlg = 1;
                },
                error:getError
            },
            aoColumns: [
                { "data": "id", "bSortable": false },
                { "data": "materielCode", "bSortable": false },
                { "data": "materielName", "bSortable": false },
                { "data": "specDesc", "bSortable": false },
                { "data": "orderUnit", "bSortable": false },
                { "data": "taxRate", "bSortable": true },
                { "data": "referPrice", "bSortable":false },
                { "data": "id", "bSortable":false },
            ],
            columnDefs: [
                {
                    "targets": [-1],
                    "orderable":false,
                    "searchable":false,
                    "render": function(data, type, full) {
                        if(!selectData[data]){
                            return '<input style="width:20px;height:20px;" type="checkbox" class="input-check" value="'+data+'" '+ (tempData[data]? 'checked' : '') +'>';
                        }
                        return '';
                    }
                }
            ],
        });
    });
    //modal 搜索按钮
    $('#search-btn').on('click', function () {

        if (searchDataTable) {
            searchDataTable.ajax.reload();
            return;
        }
    });


    //modal 选中/取消 checkbox
    $('#search_list').on('click', 'input:checkbox', function () {
        var code = $(this).val();
        if($(this).is(':checked')){
            var _tr = $(this).parents('tr');
            tempData[code] = {
                materielId:_tr.find('td').eq(0).html(),
                materielCode:_tr.find('td').eq(1).html(),
                materielName:_tr.find('td').eq(2).html(),
                specDesc:_tr.find('td').eq(3).html(),
                orderUnit:_tr.find('td').eq(4).html(),
                taxRate:_tr.find('td').eq(5).html(),
                referPrice:_tr.find('td').eq(6).html(),
                price: '',
                qty: '',
                totalPrice: '',
                remark: ''
            }
        } else {
            delete tempData[code];
        }
    });




    //modal 添加按钮
    $('#add-materiel-btn').on('click',function () {
        if($.isEmptyObject(tempData)){
            $.jBox.tip('请选择物料', '错误');
        }else {
            var html = '';
            $.each(tempData,function (i, v) {
                if(!selectData[i]){
                    var price = '';
                    if(!isNaN(v['taxRate']) && !isNaN(v['referPrice'])){
                        price =  (v['referPrice'] - (v['referPrice'] * v['taxRate'])).toFixed(4);
                    }

                    html += '<tr data-code="'+ i +'">';
                    html += '   <td>'+ v['materielId'] +'</td>';
                    html += '   <td>'+ v['materielCode'] +'</td>';
                    html += '   <td>'+ v['materielName'] +'</td>';
                    html += '   <td>'+ v['specDesc'] +'</td>';
                    html += '   <td>'+ v['orderUnit'] +'</td>';
                    html += '   <td><input disabled style="width: 80px"  name="taxRate" value="'+v['taxRate']+'"></td>';
                    html += '   <td><input disabled style="width: 80px" name="referPrice" value="'+v['referPrice']+'"></td>';
                    html += '   <td><input disabled style="width: 80px" name="price" value="'+ price +'"></td>';
                    html += '   <td><input style="width: 80px" name="qty" value="'+ v['qty'] +'"></td>';
                    html += '   <td><input disabled style="width: 80px" name="totalPrice" value="'+ v['totalPrice'] +'"></td>';
                    html += '   <td><input style="width: 100px" name="remark" value="'+ v['remark'] +'"></td>';
                    html += '   <td><a name="del-materiel">删除</a></td>';
                    html += '</tr>';
                }
                selectData[i] = v;
            });
            dateFlg = 1;
            tempData = {}; //清空临时数据
            $('#table_list tbody').append(html);
            $('#add-materiel-modal').modal('hide');
        }
    });

    //删除事件
    $(document).on('click','a[name=del-materiel]',function () {
        var _tr = $(this).parents('tr');
        delete selectData[_tr.attr('data-code')];
        _tr.remove();
    });


    $(document).on('change','input[name=qty]',function () {
        var _tr = $(this).parents('tr');
        var referPrice = _tr.find('input[name=referPrice]').val();
        var qty = $(this).val();
        _tr.find('input[name=totalPrice]').val((referPrice * qty).toFixed(4));
    });


    //提交事件
    function saveOrder() {
        if($("#warehouseId").val()==''){
            $.jBox.tip('请选择仓库');
            return;
        }

        if($("#supplierId").val()==''){
            $.jBox.tip('请选择供应商');
            return;
        }
        if($("#purchaserName").val()==''){
            $.jBox.tip('采购商抬头名称');
            return;
        }
        if($("#purchaseDate").val()==''){
            $.jBox.tip('请输入采购日期');
            return;
        }
        if($("#pre_deliveryDate").val()==''){
            $.jBox.tip('请输入预计送货日期');
            return;
        }
        if($("#contactName").val()==''){
            $.jBox.tip('请输入联系人姓名');
            return;
        }
        if($("#contactMobile").val()==''){
            $.jBox.tip('请输入联系人手机');
            return;
        }
        if($("#receiverName").val()==''){
            $.jBox.tip('请输入收货人名称');
            return;
        }
        if($("#receiverInformation").val()==''){
            $.jBox.tip('请输入收货人联系方式');
            return;
        }
        if($("#deliveryAddress").val()==''){
            $.jBox.tip('请输入送货地址');
            return;
        }

        if($.isEmptyObject(selectData)){
            $.jBox.tip('请添加物料信息');
            return;
        }
        var errMsg = '';
        var trList = $("#table_list tbody").find('tr[data-code]');
        $.each(trList, function () {
            var code = $(this).attr('data-code');
            var taxRate = $(this).find('input[name=taxRate]').val();
            var referPrice = $(this).find('input[name=referPrice]').val();
            var price = $(this).find('input[name=price]').val();
            var qty = $(this).find('input[name=qty]').val();
            var totalPrice = $(this).find('input[name=totalPrice]').val();
            var remark = $(this).find('input[name=remark]').val();

            if($.isEmptyObject(selectData[code])) {
                errMsg = '数据异常，请刷新页面后重试';
                return false;
            }
            if($.trim(taxRate) == '') {
                errMsg = '请输入税率';
                return false;
            }else if( !$.isNumeric(taxRate)) {
                errMsg = '请输入正确的税率';
                return false;
            }

            if($.trim(referPrice) == '') {
                errMsg = '请输入含税采购单价';
                return false;
            }else if( !$.isNumeric(referPrice)) {
                errMsg = '请输入正确的含税采购单价';
                return false;
            }

            if($.trim(price) == '') {
                errMsg = '请输入去税单价';
                return false;
            }else if( !$.isNumeric(price)) {
                errMsg = '请输入正确的去税单价';
                return false;
            }


            if($.trim(qty) == '') {
                errMsg = '请输入采购数量';
                return false;
            }else if( !$.isNumeric(qty)) {
                errMsg = '请输入正确的采购数量';
                return false;
            }


            if($.trim(totalPrice) == '') {
                errMsg = '请输入总金额';
                return false;
            }else if( !$.isNumeric(totalPrice)) {
                errMsg = '请输入正确的总金额';
                return false;
            }

            selectData[code]['taxRate'] = taxRate;
            selectData[code]['referPrice'] = referPrice;
            selectData[code]['price'] = price;
            selectData[code]['qty'] = qty;
            selectData[code]['totalPrice'] = totalPrice;
            selectData[code]['remark'] = remark;

        });

        if(errMsg){ $.jBox.tip(errMsg); return; }

        var orderData = {
            orderNo:orderNo,
            warehouseId: $("#warehouseId").val(),
            supplierId: $("#supplierId").val(),
            purchaserName: $("#purchaserName").val(),
            purchaseDate: $("#purchaseDate").val(),
            pre_deliveryDate: $("#pre_deliveryDate").val(),
            contactName: $("#contactName").val(),
            contactMobile: $("#contactMobile").val(),
            receiverName: $("#receiverName").val(),
            receiverInformation: $("#receiverInformation").val(),
            deliveryAddress: $("#deliveryAddress").val(),
            description: $("#description").val(),
            remark: $("#remark").val(),
            materiels:selectData
        }
        $.post('/purchase-order/save-order', orderData,
            function (data) {
                if(data.code == 200){
                    $.jBox.tip('保存成功', 'success');
                    window.setTimeout(function () {
                        history.back();
                    }, 1000);
                }else{
                    $.jBox.error(data.val, '错误');
                }
            },
            'json'
        );
    }

</script>